<?php

namespace app\common\model;

class VideoCourseware extends Base
{
    // 定义时间戳字段名
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';


    protected $suffixDict = [
        'pdf' => 'PDF文档',
        'docx' => 'Word文档',
        'pptx' => 'PPT演示文稿',
        'xlsx' => 'Excel表格',
        'rar' => '压缩文件',
        'zip' => '压缩文件',
    ];

    public function getSuffixAttr($suffix)
    {
        if (isset($this->suffixDict[$suffix])) {
            return $this->suffixDict[$suffix];
        }
        return '-';
    }

    public function getSuffixAttrByValue($suffix)
    {
        foreach ($this->suffixDict as $key => $value) {
            if (strpos($suffix, $key) !== false) {
                return $value;
            }
        }
        return '-';
    }
}